capture program drop TabulatePlot_placebo

program TabulatePlot_placebo, eclass

use Analysis/placeboresults.dta, clear

	gen coefnumber = substr(parm,-1,1)
	destring coefnumber, ignore("e" "me" "ly" "nd" "l" "is") replace
	drop if coefnumber ==. 


	gen var = 1 if strpos(parm,"before")>0
	replace var = 2 if strpos(parm,"after")>0

	replace coefnumber = - coefnumber if var==1 

	matrix b=(.)
	matrix se = (.) 
		
		
	forval event = 1(1)4{
		summ estimate if coefnumber== -4+`event' & var== 1
		local b = r(mean)
		local se = r(sd)
		matrix b = `b' \ b	
		matrix se = `se' \ se 
		}
		
		
		forval event = 1(1)3{
		summ estimate if coefnumber==`event' & var==2
		local b = r(mean)
		local se = r(sd)
		matrix b = `b' \ b	
		matrix se = `se' \ se 
		
	}
	
	

	
	matrix b = b[1..7,1]'
	matrix v = (se[1..7,1])*(se[1..7,1])'
	
	matrix b1=b
	matrix v1=v
	
	
	local dof = r(mean) 
	
	
	
	ereturn post b1 v1 

	
	matrix colnames b = "Event Period -3" "Event Period -2" "Event Period -1" "Event Period"  "Event Period +1" "Event Period +2" ///
	"Event Period +3"
	
	
	ereturn repost b=b V=v,  rename
	
 eststo placebo

	
		
	
	
	


	
	
	
coefplot (placebo, keep("Event Period -3" "Event Period -2" "Event Period -1" ) mcolor(blue) ciopts(lcolor(blue)) msymbol(o)) ///
   (placebo, keep("Event Period") mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
  (placebo, keep("Event Period +1" "Event Period +2" "Event Period +3") mcolor(red) ciopts(lcolor(red)) msymbol(o)), vertical ///
 relocate("Event Period -3"  = -2.84 "Event Period -2" = -1.84 "Event Period -1"  = -0.84 "Event Period"  = -0 ///
"Event Period +1" =0.84  "Event Period +2"=1.84 "Event Period +3"=2.84 )   legend(off) yline(0) ///
xtitle("Event time") xlabel(-3(1)3)  xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin))  yscale(range(-0.025 0.025)) ylabel(-0.02(0.01)0.02)  

graph export Analysis/Placebo_1000runs.png, replace

	
end






